package demo;


/*
作物类
 */
public abstract class Crop {
    private String name;    //名称
    private int growTime;   //成长期
    private int harvestTime;  //采摘期
    private int numsOfFruits;  //果实数量
    private String status;    //生长状态
    private boolean isHarvested;  //果实是否已收割

    public String getName() {
        return name;
    }
    public int getGrowTime() {
        return growTime;
    }
    public int getHarvestTime() {
        return harvestTime;
    }
    public int getNumsOfFruits() {
        return numsOfFruits;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public boolean isHarvested() { return isHarvested; }
    public void setHarvested(boolean harvested) { this.isHarvested = harvested; }

    public Crop(){
        this.name = "默认";
    }

    public Crop(String name, int growTime, int harvestTime, int numsOfFruits){
        this.name = name;
        this.growTime = growTime;
        this.harvestTime = harvestTime;
        this.numsOfFruits = numsOfFruits;
        this.status = Constants.GROW;
        this.isHarvested=false;
    }

    /**
     * 输出作物树特性
     */
    public void print(){
        System.out.println("*****作物特性*****");
        System.out.println("您种植了"+this.name+"。");
        System.out.println("生长期"+ this.growTime + "天,"
                +"采摘期"+ this.harvestTime + "天，"
                +"果实数量为" + this.numsOfFruits+"。");
    }

    /**
     * 输出生长报告
     * @param day
     */
    public void printGrowReport(int day){
        //System.out.println("您种植了"+this.name+",品种："+this.brand);
        if(day>=this.harvestTime+this.growTime){
            this.status = Constants.DEAD;
            System.out.println(this.name+this.status+",请尽快清理土地！");
        }
        else if(day >= this.growTime){
            this.status = Constants.MATURE;
            System.out.println(this.name + "处于"
                    +  this.status+"。");
            if(!this.isHarvested) {
                System.out.println("果实已成熟，请尽快采摘！");
            }else{
                System.out.println("果实已成熟并已采摘完毕！");
            }
        }
        else{
            this.status = Constants.GROW;
            System.out.println(this.name +"处于"
                    +  this.status+"。");
            System.out.println("已生长" + day
                    + "天,距离收获果实还有"
                    + (this.growTime - day) + "天。");
        }
    }
    /**
     * 收获果实
     */
    public void harvest(){
        //只有在成熟期才能进行收获
        if(this.status == Constants.MATURE){
            if(!this.isHarvested){
                System.out.println("收获果实"+this.numsOfFruits+"个！");
                this.isHarvested= true; ////设置本季已收获(避免重复收割)
            }else{
                System.out.println("果实已采摘！");
            }
        }else{
            System.out.println("抱歉！目前没有果实可以收割！");
        }
    }


    public  void Call(){}


    //作物除虫方法
    public abstract void disinfestation();


}
